package com.japhet.stripesdemo.common;

import lombok.Data;

@Data
public class ResponseR<T> {

    private Integer code;

    private T data;

    private String message;

    private ResponseR() {

    }

    public static ResponseR ok() {
        return setResponse(ResponseEnum.SUCCESS);
    }

    public static ResponseR error() {
        return setResponse(ResponseEnum.FAIL);
    }

    public static ResponseR setResponse(ResponseEnum result) {
        ResponseR r = new ResponseR();
        r.setCode(result.getCode());
        r.setMessage(result.getMessage());
        return r;
    }

    public ResponseR data(T obj) {
        this.setData(obj);
        return this;
    }

    public ResponseR message(String message) {
        this.setMessage(message);
        return this;
    }

    public ResponseR code(Integer code) {
        this.setCode(code);
        return this;
    }
}
